public class Date{
    public int year;
    public int month;
    public int day;
//下面是构造函数，一般用public修饰
    //在创建对象时由编译器自动调用，并在对象的生命周期内只调用一次
    public Date(int year,int month,int day){
       this.year=year;
       this.month=month;
       this.day = day;
        System.out.println("Date(int,int,int,)方法被调用了");
    }
    public void printDate(){
        System.out.println(year+"-"+month+"-"+day);
    }

    public static void main(String[] args) {
        Date d =new Date(2021,6,9);
        d.printDate();;
    }

}
